package com.bwie.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.bwie.poi.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 商品表
 * @TableName tb_prod
 */
@TableName(value ="tb_prod")
@Data
public class TbProd implements Serializable {
    /**
     * 商品ID
     */
    @TableId(type = IdType.AUTO)
    @Excel(name = "商品ID")
    private Integer prodId;

    /**
     * 商品名称
     */
    @Excel(name = "商品名称")
    private String prodName;

    /**
     * 商品类型
     */
    @Excel(name = "商品类型", readConverterExp = "1=手机,2=手表,3=汽车,4=电脑")
    private Integer prodType;

    /**
     * 商品价格
     */
    @Excel(name = "商品价格")
    private BigDecimal prodPrice;

    /**
     * 库存
     */
    @Excel(name = "商品库存")
    private Integer prodStock;

    /**
     * 商品状态：0草稿1待审核2上线3驳回4下线
     */
    @Excel(name = "审核状态", readConverterExp = "0=草稿,1=待审核,2=上线,3=驳回,4=下线")
    private Integer prodStatus;

    /**
     * 商家id
     */
    private Integer userId;

    /**
     * 录入时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8",shape  = JsonFormat.Shape.STRING)
    @Excel(name = "录入时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 驳回原因
     */
    private String reason;

    @TableField(exist = false)
    private List<String> imageList;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        TbProd other = (TbProd) that;
        return (this.getProdId() == null ? other.getProdId() == null : this.getProdId().equals(other.getProdId()))
            && (this.getProdName() == null ? other.getProdName() == null : this.getProdName().equals(other.getProdName()))
            && (this.getProdType() == null ? other.getProdType() == null : this.getProdType().equals(other.getProdType()))
            && (this.getProdPrice() == null ? other.getProdPrice() == null : this.getProdPrice().equals(other.getProdPrice()))
            && (this.getProdStock() == null ? other.getProdStock() == null : this.getProdStock().equals(other.getProdStock()))
            && (this.getProdStatus() == null ? other.getProdStatus() == null : this.getProdStatus().equals(other.getProdStatus()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getReason() == null ? other.getReason() == null : this.getReason().equals(other.getReason()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getProdId() == null) ? 0 : getProdId().hashCode());
        result = prime * result + ((getProdName() == null) ? 0 : getProdName().hashCode());
        result = prime * result + ((getProdType() == null) ? 0 : getProdType().hashCode());
        result = prime * result + ((getProdPrice() == null) ? 0 : getProdPrice().hashCode());
        result = prime * result + ((getProdStock() == null) ? 0 : getProdStock().hashCode());
        result = prime * result + ((getProdStatus() == null) ? 0 : getProdStatus().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getReason() == null) ? 0 : getReason().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", prodId=").append(prodId);
        sb.append(", prodName=").append(prodName);
        sb.append(", prodType=").append(prodType);
        sb.append(", prodPrice=").append(prodPrice);
        sb.append(", prodStock=").append(prodStock);
        sb.append(", prodStatus=").append(prodStatus);
        sb.append(", createTime=").append(createTime);
        sb.append(", reason=").append(reason);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}